﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Space_Conquest
{
    delegate void InGameMenuHandler(); 

    class InGameMenuButtons : IRender, IInput
    {
        #region Variables
            private int _x;
            private int _y;
            private int _sizeX;
            private int _sizeY;
            private string _texture;
            private Texture _TestTexture;
            private Sprite _TestSprite;
        #endregion

        #region Properties

            public int X
            {
                get
                {
                    return _x;
                }
            }

            public int Y
            {
                get
                {
                    return _y;
                }
            }

            public int Width
            {
                get
                {
                    return _sizeX;
                }
            }

            public int Height
            {
                get
                {
                    return _sizeY;
                }
            }


        #endregion

        #region Constructor
        public InGameMenuButtons(int x, int y, int sizeX, int sizeY, string texture)
        {
            _x = x;
            _y = y;
            _sizeX = sizeX;
            _sizeY = sizeY;
            _texture = texture;
            _TestTexture = new Texture(_texture);
            _TestSprite = new Sprite(x, y, sizeX, sizeY, 255, false);
        }
        #endregion

        #region Events

            public event InGameMenuHandler OnButtonClick;

         #endregion

        #region IRender Members

            public void Render()
            {
                _TestSprite.Render(_TestTexture);
            }

        #endregion

        #region IInput Members

        public bool MouseDown(System.Windows.Forms.MouseButtons button, int x, int y)
        {
            if (x - Globals.iScreenOffsetX > _TestSprite.Left && x - Globals.iScreenOffsetX < _TestSprite.Right)
                {
                    if (y - Globals.iScreenOffsetY > _TestSprite.Top && y - Globals.iScreenOffsetY < _TestSprite.Bottom)
                    {
                        if (OnButtonClick != null)
                        {
                            OnButtonClick();
                            return true;
                        }
                    }
                }

             return false;
        }

        public bool MouseUp(System.Windows.Forms.MouseButtons button, int x, int y)
        {
            return false;
        }

        public bool MouseMove(int x, int y)
        {
            return false;
        }

        public bool KeyDown(System.Windows.Forms.Keys key, bool shift)
        {
            return false;
        }

        public bool KeyUp(System.Windows.Forms.Keys key, bool shift)
        {
            return false;
        }

        #endregion
    }
}
